From: Florian Müllner Date: Thu, 22 May 2025 01:22:49 +0000 (+0200) Subject: dbusServices/extensions: Use static class blocks for gtype registration X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~119^2~4^2^2~2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=5a454642f3b34ad9f5ddc699b15be54ac39da230;p=gnome-shell.git dbusServices/extensions: Use static class blocks for gtype registration Static class blocks are a more readable alternative to _classInit(), provided we make sure to call registerClass() first. Part-of: (cherry picked from commit 9e0d159e3f871d623fbe2a08d01c7905540725b7) --- diff --git a/js/dbusServices/extensions/extensionPrefsDialog.js b/js/dbusServices/extensions/extensionPrefsDialog.js index f6061a9be..c88003124 100644 --- a/js/dbusServices/extensions/extensionPrefsDialog.js +++ b/js/dbusServices/extensions/extensionPrefsDialog.js @@ -7,12 +7,16 @@ import Gtk from 'gi://Gtk?version=4.0'; import {formatError} from './misc/errorUtils.js'; -export const ExtensionPrefsDialog = GObject.registerClass({ - GTypeName: 'ExtensionPrefsDialog', - Signals: { +export class ExtensionPrefsDialog extends Adw.PreferencesWindow { + static [GObject.GTypeName] = 'ExtensionPrefsDialog'; + static [GObject.signals] = { 'loaded': {}, - }, -}, class ExtensionPrefsDialog extends Adw.PreferencesWindow { + }; + + static { + GObject.registerClass(this); + } + constructor(extension) { super({ title: extension.metadata.name, @@ -66,32 +70,32 @@ export const ExtensionPrefsDialog = GObject.registerClass({ this.add(new ExtensionPrefsErrorPage(this._extension, e)); } -}); +} -const ExtensionPrefsErrorPage = GObject.registerClass({ - GTypeName: 'ExtensionPrefsErrorPage', - Template: 'resource:///org/gnome/Shell/Extensions/ui/extension-error-page.ui', - InternalChildren: [ +class ExtensionPrefsErrorPage extends Adw.PreferencesPage { + static [GObject.GTypeName] = 'ExtensionPrefsErrorPage'; + static [Gtk.template] = + 'resource:///org/gnome/Shell/Extensions/ui/extension-error-page.ui'; + + static [Gtk.internalChildren] = [ 'expander', 'expanderArrow', 'revealer', 'errorView', - ], -}, class ExtensionPrefsErrorPage extends Adw.PreferencesPage { - static _classInit(klass) { - super._classInit(klass); + ]; + + static { + GObject.registerClass(this); - klass.install_action('page.copy-error', + this.install_action('page.copy-error', null, self => { const clipboard = self.get_display().get_clipboard(); clipboard.set(self._errorMarkdown); }); - klass.install_action('page.show-url', + this.install_action('page.show-url', null, self => Gtk.show_uri(self.get_root(), self._url, Gdk.CURRENT_TIME)); - - return klass; } constructor(extension, error) { @@ -157,4 +161,4 @@ const ExtensionPrefsErrorPage = GObject.registerClass({ provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); } -}); +}